package com.ztx.jpaSpring.service;

import com.ztx.jpaSpring.dao.PersonDao;
import com.ztx.jpaSpring.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * PersonService--jpa-Demo
 *
 * @author: Jovi
 * @createTime: 2018-08-09 16:36
 **/
@Service
public class PersonService {

    @Autowired
    private PersonDao personDao;

    @Transactional(rollbackFor = Exception.class)
    public void savePersons(Person p1, Person p2) {
        personDao.save(p1);

        int s = 10 /0;

        personDao.save(p2);
    }
}
